﻿using System;
using System.Data;
using System.Text;
using System.Collections.Generic;
using System.Data.OracleClient;
namespace GSLMS.DAL.Oracle
{
	/// <summary>
	/// 数据访问类:APP_PROREPORTINFO
	/// </summary>
	public partial class APP_PROREPORTINFO : BaseDAL<GSLMS.Entity.TB_APP_PROREPORTINFO>
	{
		private readonly GSLMS.Core.Loger log = new Core.Loger();
		public APP_PROREPORTINFO()
		{}
		#region  Method
		/// <summary>
		///  增加一条数据
		/// </summary>
		public override bool Add(GSLMS.Entity.TB_APP_PROREPORTINFO model)
		{
			bool flag = false;
			OracleParameter[] parms =new OracleParameter[]{
								new OracleParameter("P_ID", model.ID),
								new OracleParameter("P_PROID", model.PROID),
								new OracleParameter("P_REGINFOID", model.REGINFOID),
								new OracleParameter("P_BUSSDETAIL", model.BUSSDETAIL),
								new OracleParameter("P_REGDETAIL", model.REGDETAIL),
								new OracleParameter("P_CORPNAME", model.CORPNAME),
								new OracleParameter("P_CREATEDATE", model.CREATEDATE),
								new OracleParameter("P_REGCAPTAIL", model.REGCAPTAIL),
								new OracleParameter("P_LEGALMAN", model.LEGALMAN),
								new OracleParameter("P_BUSSTERM", model.BUSSTERM),
								new OracleParameter("P_LOANNO", model.LOANNO),
								new OracleParameter("P_CONBY", model.CONBY),
								new OracleParameter("P_ANNCHECK", model.ANNCHECK),
								new OracleParameter("P_REGADDR", model.REGADDR),
								new OracleParameter("P_REGADDRTYPE", model.REGADDRTYPE),
								new OracleParameter("P_REGTELCODE", model.REGTELCODE),
								new OracleParameter("P_REGTEL", model.REGTEL),
								new OracleParameter("P_REGTELSUB", model.REGTELSUB),
								new OracleParameter("P_WORKADDR", model.WORKADDR),
								new OracleParameter("P_WORKTELCODE", model.WORKTELCODE),
								new OracleParameter("P_WORKTEL", model.WORKTEL),
								new OracleParameter("P_WORKTELSUB", model.WORKTELSUB),
								new OracleParameter("P_ISSPECAILCER", model.ISSPECAILCER),
								new OracleParameter("P_HAVESPECAILCERS", model.HAVESPECAILCERS),
								new OracleParameter("P_LEGALHOUADDR", model.LEGALHOUADDR),
								new OracleParameter("P_LEGALADDR", model.LEGALADDR),
								new OracleParameter("P_LEGALTEL", model.LEGALTEL),
								new OracleParameter("P_LEGALTEL2", model.LEGALTEL2),
								new OracleParameter("P_CONBYADDR", model.CONBYADDR),
								new OracleParameter("P_CONBYTEL", model.CONBYTEL),
								new OracleParameter("P_CONBYTEL2", model.CONBYTEL2),
								new OracleParameter("P_OTHERREMARK", model.OTHERREMARK),
								new OracleParameter("P_SURVEYBY", model.SURVEYBY),
								new OracleParameter("P_SURVEYTIME", model.SURVEYTIME),
								new OracleParameter("P_STATUS", model.STATUS),
								new OracleParameter("P_SPAREFIELD1", model.SPAREFIELD1),
								new OracleParameter("P_SPAREFIELD2", model.SPAREFIELD2),
								new OracleParameter("P_SPAREFIELD3", model.SPAREFIELD3)};
  
			for (int i = 0; i < 38; i++)
			{
				parms[i].Direction = ParameterDirection.Input;
			}

			try
			{
				OracleHelper.ExecuteNonQuery(OracleHelper.connectionString, CommandType.StoredProcedure, "pkg_apply.proc_app_proreportinfo_add", parms);
				flag = true;
			}
			catch (Exception ex)
			{
				log.ExceptionHand(ex);
			}
			return flag;
		}

		/// <summary>
		///  更新一条数据
		/// </summary>
		public override bool Update(GSLMS.Entity.TB_APP_PROREPORTINFO model)
		{
			bool flag = false;
			OracleParameter[] parms =new OracleParameter[]{
								new OracleParameter("P_ID", model.ID),
								new OracleParameter("P_PROID", model.PROID),
								new OracleParameter("P_REGINFOID", model.REGINFOID),
								new OracleParameter("P_BUSSDETAIL", model.BUSSDETAIL),
								new OracleParameter("P_REGDETAIL", model.REGDETAIL),
								new OracleParameter("P_CORPNAME", model.CORPNAME),
								new OracleParameter("P_CREATEDATE", model.CREATEDATE),
								new OracleParameter("P_REGCAPTAIL", model.REGCAPTAIL),
								new OracleParameter("P_LEGALMAN", model.LEGALMAN),
								new OracleParameter("P_BUSSTERM", model.BUSSTERM),
								new OracleParameter("P_LOANNO", model.LOANNO),
								new OracleParameter("P_CONBY", model.CONBY),
								new OracleParameter("P_ANNCHECK", model.ANNCHECK),
								new OracleParameter("P_REGADDR", model.REGADDR),
								new OracleParameter("P_REGADDRTYPE", model.REGADDRTYPE),
								new OracleParameter("P_REGTELCODE", model.REGTELCODE),
								new OracleParameter("P_REGTEL", model.REGTEL),
								new OracleParameter("P_REGTELSUB", model.REGTELSUB),
								new OracleParameter("P_WORKADDR", model.WORKADDR),
								new OracleParameter("P_WORKTELCODE", model.WORKTELCODE),
								new OracleParameter("P_WORKTEL", model.WORKTEL),
								new OracleParameter("P_WORKTELSUB", model.WORKTELSUB),
								new OracleParameter("P_ISSPECAILCER", model.ISSPECAILCER),
								new OracleParameter("P_HAVESPECAILCERS", model.HAVESPECAILCERS),
								new OracleParameter("P_LEGALHOUADDR", model.LEGALHOUADDR),
								new OracleParameter("P_LEGALADDR", model.LEGALADDR),
								new OracleParameter("P_LEGALTEL", model.LEGALTEL),
								new OracleParameter("P_LEGALTEL2", model.LEGALTEL2),
								new OracleParameter("P_CONBYADDR", model.CONBYADDR),
								new OracleParameter("P_CONBYTEL", model.CONBYTEL),
								new OracleParameter("P_CONBYTEL2", model.CONBYTEL2),
								new OracleParameter("P_OTHERREMARK", model.OTHERREMARK),
								new OracleParameter("P_SURVEYBY", model.SURVEYBY),
								new OracleParameter("P_SURVEYTIME", model.SURVEYTIME),
								new OracleParameter("P_STATUS", model.STATUS),
								new OracleParameter("P_SPAREFIELD1", model.SPAREFIELD1),
								new OracleParameter("P_SPAREFIELD2", model.SPAREFIELD2),
								new OracleParameter("P_SPAREFIELD3", model.SPAREFIELD3)};
  
			for (int i = 0; i < 38; i++)
			{
				parms[i].Direction = ParameterDirection.Input;
			}

			try
			{
				OracleHelper.ExecuteNonQuery(OracleHelper.connectionString, CommandType.StoredProcedure, "pkg_apply.proc_app_proreportinfo_update", parms);
				flag = true;
			}
			catch (Exception ex)
			{
				log.ExceptionHand(ex);
			}
			return flag;
		}

		/// <summary>
		///  删除一条数据
		/// </summary>
		public override bool Delete(long ID)
		{
			bool flag = false;
			OracleParameter[] parms =new OracleParameter[]{
								new OracleParameter("P_ID", ID)};
  
				parms[0].Direction = ParameterDirection.Input;

			try
			{
				OracleHelper.ExecuteNonQuery(OracleHelper.connectionString, CommandType.StoredProcedure, "pkg_apply.proc_app_proreportinfo_delete", parms);
				flag = true;
			}
			catch (Exception ex)
			{
				log.ExceptionHand(ex);
			}
			return flag;
		}

		/// <summary>
		///DataRowToModel 
		/// </summary>
		private GSLMS.Entity.TB_APP_PROREPORTINFO DataRowToModel(DataRow dr)
		{
			if (dr != null && dr.ItemArray.Length > 0)
			{
				GSLMS.Entity.TB_APP_PROREPORTINFO model = new GSLMS.Entity.TB_APP_PROREPORTINFO();
				if(dr["ID"]!=null && dr["ID"].ToString()!="")
				{
					model.ID=OracleHelper.ToLong(dr["ID"].ToString());
				}
				if(dr["PROID"]!=null && dr["PROID"].ToString()!="")
				{
					model.PROID=OracleHelper.ToLong(dr["PROID"].ToString());
				}
				if(dr["REGINFOID"]!=null && dr["REGINFOID"].ToString()!="")
				{
					model.REGINFOID=OracleHelper.ToLong(dr["REGINFOID"].ToString());
				}
				if(dr["BUSSDETAIL"]!=null && dr["BUSSDETAIL"].ToString()!="")
				{
					model.BUSSDETAIL=dr["BUSSDETAIL"].ToString();
				}
				if(dr["REGDETAIL"]!=null && dr["REGDETAIL"].ToString()!="")
				{
					model.REGDETAIL=dr["REGDETAIL"].ToString();
				}
				if(dr["CORPNAME"]!=null && dr["CORPNAME"].ToString()!="")
				{
					model.CORPNAME=dr["CORPNAME"].ToString();
				}
				if(dr["CREATEDATE"]!=null && dr["CREATEDATE"].ToString()!="")
				{
					model.CREATEDATE=DateTime.Parse(dr["CREATEDATE"].ToString());
				}
				if(dr["REGCAPTAIL"]!=null && dr["REGCAPTAIL"].ToString()!="")
				{
					model.REGCAPTAIL=OracleHelper.ToDecimal(dr["REGCAPTAIL"].ToString());
				}
				if(dr["LEGALMAN"]!=null && dr["LEGALMAN"].ToString()!="")
				{
					model.LEGALMAN=dr["LEGALMAN"].ToString();
				}
				if(dr["BUSSTERM"]!=null && dr["BUSSTERM"].ToString()!="")
				{
					model.BUSSTERM=OracleHelper.ToDecimal(dr["BUSSTERM"].ToString());
				}
				if(dr["LOANNO"]!=null && dr["LOANNO"].ToString()!="")
				{
					model.LOANNO=dr["LOANNO"].ToString();
				}
				if(dr["CONBY"]!=null && dr["CONBY"].ToString()!="")
				{
					model.CONBY=dr["CONBY"].ToString();
				}
				if(dr["ANNCHECK"]!=null && dr["ANNCHECK"].ToString()!="")
				{
					model.ANNCHECK=dr["ANNCHECK"].ToString();
				}
				if(dr["REGADDR"]!=null && dr["REGADDR"].ToString()!="")
				{
					model.REGADDR=dr["REGADDR"].ToString();
				}
				if(dr["REGADDRTYPE"]!=null && dr["REGADDRTYPE"].ToString()!="")
				{
					model.REGADDRTYPE=dr["REGADDRTYPE"].ToString();
				}
				if(dr["REGTELCODE"]!=null && dr["REGTELCODE"].ToString()!="")
				{
					model.REGTELCODE=dr["REGTELCODE"].ToString();
				}
				if(dr["REGTEL"]!=null && dr["REGTEL"].ToString()!="")
				{
					model.REGTEL=dr["REGTEL"].ToString();
				}
				if(dr["REGTELSUB"]!=null && dr["REGTELSUB"].ToString()!="")
				{
					model.REGTELSUB=dr["REGTELSUB"].ToString();
				}
				if(dr["WORKADDR"]!=null && dr["WORKADDR"].ToString()!="")
				{
					model.WORKADDR=dr["WORKADDR"].ToString();
				}
				if(dr["WORKTELCODE"]!=null && dr["WORKTELCODE"].ToString()!="")
				{
					model.WORKTELCODE=dr["WORKTELCODE"].ToString();
				}
				if(dr["WORKTEL"]!=null && dr["WORKTEL"].ToString()!="")
				{
					model.WORKTEL=dr["WORKTEL"].ToString();
				}
				if(dr["WORKTELSUB"]!=null && dr["WORKTELSUB"].ToString()!="")
				{
					model.WORKTELSUB=dr["WORKTELSUB"].ToString();
				}
				if(dr["ISSPECAILCER"]!=null && dr["ISSPECAILCER"].ToString()!="")
				{
                    model.ISSPECAILCER = OracleHelper.ToInt(dr["ISSPECAILCER"].ToString());
				}
				if(dr["HAVESPECAILCERS"]!=null && dr["HAVESPECAILCERS"].ToString()!="")
				{
					model.HAVESPECAILCERS=dr["HAVESPECAILCERS"].ToString();
				}
				if(dr["LEGALHOUADDR"]!=null && dr["LEGALHOUADDR"].ToString()!="")
				{
					model.LEGALHOUADDR=dr["LEGALHOUADDR"].ToString();
				}
				if(dr["LEGALADDR"]!=null && dr["LEGALADDR"].ToString()!="")
				{
					model.LEGALADDR=dr["LEGALADDR"].ToString();
				}
				if(dr["LEGALTEL"]!=null && dr["LEGALTEL"].ToString()!="")
				{
					model.LEGALTEL=dr["LEGALTEL"].ToString();
				}
				if(dr["LEGALTEL2"]!=null && dr["LEGALTEL2"].ToString()!="")
				{
					model.LEGALTEL2=dr["LEGALTEL2"].ToString();
				}
				if(dr["CONBYADDR"]!=null && dr["CONBYADDR"].ToString()!="")
				{
					model.CONBYADDR=dr["CONBYADDR"].ToString();
				}
				if(dr["CONBYTEL"]!=null && dr["CONBYTEL"].ToString()!="")
				{
					model.CONBYTEL=dr["CONBYTEL"].ToString();
				}
				if(dr["CONBYTEL2"]!=null && dr["CONBYTEL2"].ToString()!="")
				{
					model.CONBYTEL2=dr["CONBYTEL2"].ToString();
				}
				if(dr["OTHERREMARK"]!=null && dr["OTHERREMARK"].ToString()!="")
				{
					model.OTHERREMARK=dr["OTHERREMARK"].ToString();
				}
				if(dr["SURVEYBY"]!=null && dr["SURVEYBY"].ToString()!="")
				{
					model.SURVEYBY=dr["SURVEYBY"].ToString();
				}
				if(dr["SURVEYTIME"]!=null && dr["SURVEYTIME"].ToString()!="")
				{
					model.SURVEYTIME=DateTime.Parse(dr["SURVEYTIME"].ToString());
				}
				if(dr["STATUS"]!=null && dr["STATUS"].ToString()!="")
				{
                    model.STATUS = OracleHelper.ToInt(dr["STATUS"].ToString());
				}
				if(dr["SPAREFIELD1"]!=null && dr["SPAREFIELD1"].ToString()!="")
				{
                    model.SPAREFIELD1 = OracleHelper.ToInt(dr["SPAREFIELD1"].ToString());
				}
				if(dr["SPAREFIELD2"]!=null && dr["SPAREFIELD2"].ToString()!="")
				{
					model.SPAREFIELD2=dr["SPAREFIELD2"].ToString();
				}
				if(dr["SPAREFIELD3"]!=null && dr["SPAREFIELD3"].ToString()!="")
				{
					model.SPAREFIELD3=dr["SPAREFIELD3"].ToString();
				}
				return model;
			}
			else
			{
				return null;
			}
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public override GSLMS.Entity.TB_APP_PROREPORTINFO GetByID(long ID)
		{
			GSLMS.Entity.TB_APP_PROREPORTINFO sModel = new GSLMS.Entity.TB_APP_PROREPORTINFO();
			string sql = "";
			sql = "select * from TB_APP_PROREPORTINFO where id=" + ID.ToString();
			DataSet ds = OracleHelper.ExecuteDataset(sql);
			if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
			{
				sModel = DataRowToModel(ds.Tables[0].Rows[0]);
			}
			else
			{
			return null;
			}
			return sModel;
		}

		/// <summary>
		/// 分页提取数据
		/// </summary>
		public override List<GSLMS.Entity.TB_APP_PROREPORTINFO> GetList(GSLMS.Entity.TB_APP_PROREPORTINFO searchParam)
		{
			var list=new List<GSLMS.Entity.TB_APP_PROREPORTINFO>();
			DataTable dt = null;
			string tblName = "TB_APP_PROREPORTINFO";
			string sqlWhere="";
			string strSort="";
			int pageSize=20;
			int pageIndex=1;
			string strFields="*";
			int totalCount = 0;
			int countFlag = 1;
			dt = OracleHelper.GetPageData(tblName, strFields, strSort, pageSize, pageIndex,countFlag, sqlWhere, out totalCount);
			if (dt != null && dt.Rows.Count > 0)
			{
				for (int i = 0; i < dt.Rows.Count; i++)
				{
					GSLMS.Entity.TB_APP_PROREPORTINFO model = new GSLMS.Entity.TB_APP_PROREPORTINFO();
					model = DataRowToModel(dt.Rows[i]);
					list.Add(model);
				}
			}
			else
			{
				return null;
			}
			return list;
		}

		#endregion  Method
	}
}

